﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using mobile.bg.Extras;

namespace mobile.bg
{
    public partial class MobilePage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            List<IExtras> extras = new List<IExtras>();
            extras.Add(new Abs { Name = "Abs", hasExtra = true });
            extras.Add(new Quatro { Name = "Quatro", hasExtra = true });

            this.extrasList.DataSource = extras;
            this.producer.DataSource = Producer.GetProducers();
            

            if (!Page.IsPostBack)
            {
                this.producer.DataBind();
                this.extrasList.DataBind();

                foreach (ListItem item in this.extrasList.Items)
                {
                    //item.Selected = item.
                }
            }

            producer_SelectedIndexChanged(this.producer, EventArgs.Empty);


        }

        protected void producer_SelectedIndexChanged(object sender, EventArgs e)
        {
            //int index;
            //int.TryParse(this.producer.SelectedIndex,out index);
            List<Producer> producers = Producer.GetProducers();
            this.model.DataSource = producers[this.producer.SelectedIndex].Models;
            this.model.DataBind();
        }
    }
}